package com.connector.server.server.listener;

import org.slf4j.LoggerFactory;
import com.connector.base.connection.channel.SocketChannel;
import com.connector.base.connection.Connection;
import com.alibaba.fastjson.JSON;
import com.connector.base.connection.channel.SocketIoSocketChannel;
import com.connector.base.connection.impl.SocketIoConnection;
import com.corundumstudio.socketio.SocketIOClient;
import com.connector.base.connection.ConnectionRegistry;
import org.slf4j.Logger;
import com.corundumstudio.socketio.listener.ConnectListener;

public class SocketIoConnectListener implements ConnectListener
{
    private static final Logger log;
    private final ConnectionRegistry connectionRegistry;
    
    public SocketIoConnectListener(final ConnectionRegistry connectionRegistry) {
        this.connectionRegistry = connectionRegistry;
    }
    
    public void onConnect(final SocketIOClient socketIOClient) {
        final Connection connection = (Connection)new SocketIoConnection();
        final SocketChannel channel = (SocketChannel)new SocketIoSocketChannel(socketIOClient);
        connection.init(channel);
        this.connectionRegistry.add(connection);
        SocketIoConnectListener.log.info("申请链接......" + JSON.toJSONString((Object)connection.getSessionContext()));
    }
    
    static {
        log = LoggerFactory.getLogger((Class)SocketIoConnectListener.class);
    }
}
